/**
 * deleteSection() submits a form to delete a section
*/
function deleteSection(section_id) {

	// Confirm choice
	if (confirm("Are you sure you want to delete the section '" + section_id + "' and any pages within it?")) {

		// Set hidden var
		document.getElementById("deletesection").value = section_id;

		// Submit form
		document.getElementById("deletesectionform").submit();
	}
}


/**
 * deleteUploadedFile() submits a form to delete an uploaded file
*/
function deleteUploadedFile(file_name) {

	// Confirm choice
	if (confirm("Are you sure you wish to delete this file? This action cannot be undone.")) {

		// Set hidden var
		document.getElementById("deletefile").value = file_name;

		// Submit form
		document.getElementById("deletefileform").submit();
	}
}


/**
 * getNewNewsletterName() gets a new newsletter's name, and submits the form
*/
function getNewNewsletterName() {

	var newsletter_name = prompt("Please enter a name for this newsletter:");

	if (newsletter_name != "" && newsletter_name != false && newsletter_name) {
		doAction("addnewsletter", newsletter_name, false);
	}
}


/**
 * doAction() does a generic action in the admin
 *
 * @param mode is the mode of action (delete, edit)
 * @param id is the ID for the action
 * @param confirm_required is whether a confirmation should be obtained before doing the action
*/
function doAction(mode, id, confirm_required) {

	// OK to proceed?
	var proceed_ok = true;

	// If confirmation is required, get it now
	if (confirm_required) {
		proceed_ok = confirm("Are you sure you want to proceed?");
	}

	if (proceed_ok) {
		document.getElementById("id").value = id;
		document.getElementById("mode").value = mode;
		document.getElementById("actionform").submit();
	}
}

function toggle(link, id) { 
	confirm(id);
	 var lText = link.innerHTML;
 	if (lText == '+') { 
	link.innerHTML = '−'; 
	}
 	else { 
	link.innerHTML = '+';
	}
	confirm(id);
	document.getElementById("test").value=id;
	document.getElementById("actionform").submit();
}

/**
 * openQuickUploadWin() opens the quick uploader window
*/
function openQuickUploadWin() {

	window.open("../admin/quickupload.php", "quickupload", "height=550,width=500,location=0,menubar=0,resizable=0,personalbar=0,screenx=10,screeny=10,scrollbars=1");
}

/**
 * editGroupUsers() opens the window to edit the Group Users
 *
 * @param group_id is the id of the group
*/
function editGroupUsers(group_id) {

	window.open("../admin/groupusers.php?group=" + group_id, "groupusers", "height=550,width=400,location=0,menubar=0,resizable=0,personalbar=0,screenx=10,screeny=10,scrollbars=1");
}

/**
 * editNewsletterGroupUsers() opens the window to edit the Newsletter Group users
 *
 * @param newsletter_group_id is the newsletter group ID
*/
function editNewsletterGroupUsers(newsletter_group_id) {

	window.open("../admin/adminnewslettergroupusers.php?group=" + newsletter_group_id, "newslettergroupusers", "height=550,width=400,location=0,menubar=0,resizable=0,personalbar=0,screenx=10,screeny=10");
}


/**
 * moveUserToGroup() moves a user to a group
 *
 * @param user_id is the User ID
*/
function moveUserToGroup(user_id) {

	document.getElementById("userid").value = user_id;
	document.getElementById("moveuserform").submit();
}


/**
 * launchPageMove() launches the page moving popup
 *
 * @param page_id is the page to select
*/
function launchPageMove(page_id) {
	
	window.open("../admin/adminpagemove.php?page=" + page_id, "pagemove", "height=700,width=700,location=0,menubar=0,resizable=0,personalbar=0,screenx=10,screeny=10");
}

function launchPopUp(gl_id){
	
}


/**
 * launchPagePreview launches the page preview popup
*/
function launchPagePreview(page_id) {
	window.open("../includes/pagepreview.php?page=" + page_id, "pagepreview", "height=550,width=780,location=0,menubar=0,resizable=0,personalbar=0,screenx=10,screeny=10");
}


/**
 * editPageContent() launches the page edit popup
 *
 * @param page_id is the page to edit
*/
function editPageContent(page_id, type) {

	// Get Type
	type = (type) ? type : "page";

	// Open
	window.open("../admin/adminpageedit.php?page=" + page_id + "&type=" + type, "pageedit", "height=550,width=780,location=0,menubar=0,resizable=1,personalbar=0,screenx=10,screeny=10");
}


/**
 * setSelectedPagePath() sets the parent and section of a page
 *
 * @param parent_id is the ID of the parent
 * @param section_id is the section ID
*/
function setSelectedPagePath(parent_id, section_id) {

	document.getElementById("p-parent").value = parent_id;
	document.getElementById("p-section").value = section_id;
}


/**
 * reloadOpener() reloads the page that opened this page
*/
function reloadOpener() {
	window.opener.location.reload();
}


/**
 * closeWindow() closes this window
*/
function closeWindow() {
	window.close();
}


/**
 * openSelectUploadedImageWin() opens the 'select uploaded image' popup
 *
 * @param source_input_id is the ID of the <input> containing the currently selected image
*/
function openSelectUploadedImageWin(source_input_id) {

	// Get current value of input
	var current_image = document.getElementById(source_input_id).value;

	// Open
	window.open("../admin/selectuploadedimage.php?field=" + source_input_id + "&selected=" + current_image, "selectimage", "height=550,width=780,location=0,menubar=0,resizable=0,personalbar=0,screenx=10,screeny=10,scrollbars=1");
}


/**
 * selectImageListImage() selects an image list image
 *
 * @param image_id is the image ID
*/
function selectImageListImage(image_id) {

	// Deactivate previous image
	if (selected_image_id != -1) {
		document.getElementById("image-" + selected_image_id).className = "";
	}

	// Activate this image
	selected_image_id = image_id;

	// Hilight
	document.getElementById("image-" + image_id).className = "selected";

	// Make sure button is on
	document.getElementById("useimagebutton").disabled = false;
}


/**
 * finishSelectingImageListImage() finishes selecting an image
 *
 * @param use_no_image is whether to not use an image at all
*/
function finishSelectingImageListImage(use_no_image) {

	// Set selected image
	if (use_no_image) {

		// No source
		window.opener.document.getElementById(image_field).value = "";

		// Close
		closeWindow();

	} else {

		// Get Source
		var image_source = document.getElementById("image-" + selected_image_id).innerHTML.toLowerCase();
		image_source = image_source.substr(image_source.indexOf("<br"));
		image_source = image_source.substr(image_source.indexOf(">") + 1);
		image_source = image_source.substr(0, image_source.indexOf("<"));

		// Set source
		window.opener.document.getElementById(image_field).value = image_source;

		// Close
		closeWindow();
	}
}


/**
 * openChangePasswordAdminWin() opens the admin change password window
 *
 * @param user_id is the user ID
*/
function openChangePasswordAdminWin(user_id) {

	// Open
	window.open("../admin/adminuserpassword.php?userid=" + user_id, "adminchangepasswordwin", "height=550,width=720,location=0,menubar=0,resizable=0,personalbar=0,screenx=10,screeny=10");
}


/**
 * openChangePasswordWin() opens the change password window
 *
 * @param user_id is the user ID
*/
function openChangePasswordWin() {

	// Open
	window.open("../site/changeuserpassword.php", "changepasswordwin", "height=550,width=720,location=0,menubar=0,resizable=0,personalbar=0,screenx=10,screeny=10");
}


function pageTo(page) {

	document.getElementById("result").value = page;
	document.getElementById("searchitemform").submit();
}

function change_selectedfilter(filter_value,pageID){
	document.getElementById('filter').value = filter_value; 
	var value = document.getElementById('search').value;
	var filter_glossary = "";
	if(pageID == 'adminglossary'){
		
		filter_glossary = document.getElementById('id_search_filter').value;
	}
	
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function()
  	{
  		if (xmlhttp.readyState==4 && xmlhttp.status==200)
    	{
    		document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    	}
  	}

	xmlhttp.open("GET","../includes/custom/adminlivesearch.php?v="+value+"&id="+pageID+"&filter="+filter_value,true);
	xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp.send();
}

function addSymbolIn(text,id){
	//var textarea=document.getElementById(id);
//	textarea.focus();
//	
//	if (document.selection) {
//    textarea.focus();
//    var sel = document.selection.createRange();
//    sel.text = Symbol;
//  	}
//  //MOZILLA/NETSCAPE support
//  	else if (textarea.selectionStart || textarea.selectionStart == '0') {
//    	var startPos = textarea.selectionStart;
//    	var endPos = textarea.selectionEnd;
//    	textarea.value = textarea.value.substring(0, startPos)
//                  + Symbol
//                  + textarea.value.substring(endPos, myField.value.length);
//  	} else {
//    textarea.value += Symbol;
//  	}
	var obj=document.getElementById(id);
	if(document.selection) {
			obj.focus();
			var orig = obj.value.replace(/\r\n/g, "\n");
			var range = document.selection.createRange();

			if(range.parentElement() != obj) {
				return false;
			}

			range.text = text;

			var actual = tmp = obj.value.replace(/\r\n/g, "\n");

			for(var diff = 0; diff < orig.length; diff++) {
				if(orig.charAt(diff) != actual.charAt(diff)) break;
			}

			for(var index = 0, start = 0;
				tmp.match(text)
					&& (tmp = tmp.replace(text, ""))
					&& index <= diff;
				index = start + text.length
			) {
				start = actual.indexOf(text, index);
			}
		} else if(obj.selectionStart) {
			var start = obj.selectionStart;
			var end   = obj.selectionEnd;

			obj.value = obj.value.substr(0, start)
				+ text
				+ obj.value.substr(end, obj.value.length);
		}

		if(start != null) {
			setCaretTo(obj, start + text.length);
		} else {
			obj.value += text;
		}
}

function setCaretTo(obj, pos) {
		if(obj.createTextRange) {
			var range = obj.createTextRange();
			range.move('character', pos);
			range.select();
		} else if(obj.selectionStart) {
			obj.focus();
			obj.setSelectionRange(pos, pos);
		}
	}

function ShowPanel(id){
	obj = document.getElementById(id);
	obj.style.display = (obj.style.display == 'block') ? 'none' : 'block';
}

function selectPage() {

	pageTo(document.getElementById("selectpageresult").selectedIndex + 1);
}


function callTool(tool_id) {
	document.getElementById("tool").value = tool_id;
	document.getElementById("toolform").submit();
}

function openGlossary(content){
	alert(content);
}

function showOrphan(str,user){
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
	
  		xmlhttp=new XMLHttpRequest();
  	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function()
  	{
  		if (xmlhttp.readyState==4 && xmlhttp.status==200)
    	{
			
    		document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    	}
  	}
  	xmlhttp.open("GET","../includes/custom/adminpagefilter.php?q="+str+"&u="+user,true);
	xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
  	xmlhttp.send();
}

function foo(id,section){
	var hyperid="a_"+id;
	if(id=='')
	{
		if(section=='admin')
		{
			document.getElementById('a_admin').style.backgroundColor="#ADD8E6";
		}
		else if(section=='site')
		{
			document.getElementById('a_site').style.backgroundColor="#ADD8E6";
		}
	}
	else
	{
		document.getElementById(hyperid).style.backgroundColor="#ADD8E6";
	}
	if(document.getElementById("lblSelected").innerHTML!='' || document.getElementById("p-section").value!='')
	{
		if(document.getElementById("lblSelected").innerHTML!='')
		{
			var pre_id=document.getElementById("lblSelected").innerHTML.toString();
			document.getElementById("a_"+pre_id).style.backgroundColor="";
		}
		else if(document.getElementById("lblSelected").innerHTML=='')
		{			
			var pre_section=document.getElementById("p-section").value;
			document.getElementById("a_"+pre_section).style.backgroundColor="";
		}
	}
	
	document.getElementById("lblSelected").innerHTML=id;
	document.getElementById("p-parent").value=id;
	document.getElementById("p-section").value=section;
}

function toggleBgColor( elem )
{
    var style2 = elem.style;
    style2.backgroundColor = style2.backgroundColor? "":"#FFFF00";
}

function itemSelected(id,parent,section){
	var hyperid="a_"+id;
	document.getElementById(hyperid).style.backgroundColor="#ADD8E6";
	if(document.getElementById("lblSelected").innerHTML!=''){
		var pre_id=document.getElementById("lblSelected").innerHTML.toString();
		document.getElementById("a_"+pre_id).style.backgroundColor="";
	}
	document.getElementById("lblSelected").innerHTML=id;
	document.getElementById("lblSelectedParent").innerHTML=parent;
	document.getElementById("lblSelectedSection").innerHTML=section;
	document.getElementById("img_up").style.display="inline";
	document.getElementById("img_down").style.display="inline";
	
}
function err()
{
     alert("XDR onerror");
}

function timeo()
{
	//alert("XDR ontimeout");
}

function progres()
{
	//alert("XDR onprogress");
	//alert("Got: " + xdr.responseText);
}

//move order up or down, up or down is decided by flag.
function MoveUpDown(flag)
{
	  var id=document.getElementById("lblSelected").innerHTML;
	  var elementID='div'+id;
	  var parent=document.getElementById("lblSelectedParent").innerHTML;
	  var parentid='div'+parent;
	  var section=document.getElementById("lblSelectedSection").innerHTML;
	  var sectionid='div'+section;
	  if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
	  }
	  else
	  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	
	  xmlhttp.onreadystatechange=function()
	  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		  {
			  if(parent=='')
			  {
				  document.getElementById(sectionid).innerHTML=xmlhttp.responseText;			
			  }
			  else
			  {
				  document.getElementById(parentid).innerHTML=xmlhttp.responseText;
			  }
			  var hyperid="a_"+id;
			  document.getElementById(hyperid).style.backgroundColor="#ADD8E6";
		  }
	  }
	  if(flag==true)
	  {
		  xmlhttp.open("GET","../includes/custom/adminpagesmovehtml.php?id="+id+"&parent="+parent+"&action=up&section="+section,true);
	  }
	  else
	  {
		  xmlhttp.open("GET","../includes/custom/adminpagesmovehtml.php?id="+id+"&parent="+parent+"&action=down&section="+section,true);
	  }
	  xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	  xmlhttp.send();
}

function ExpandParentPage(section,id){
	
	var elementID = '';
	var imgID = ''
	
	if(section != 'junkbox'){
		if(id == ''){
		
			elementID = 'div_'+section;
			imgID = 'img_'+section;
		}
		else{
		
			elementID = 'div_'+id;
			imgID = 'img_'+id;
		}
	}
	else{
		if(id == '')
		{
			elementID = 'div_'+section+'_junk';
			imgID = 'img_'+section+'_junk';
		}
		else
		{
			elementID = 'div_'+id+'_junk';
			imgID = 'img_'+id+'_junk';
		}
	}
	
	if(document.getElementById(elementID).innerHTML!='')
	{
		document.getElementById(imgID).src="../assets/images/tree/folder_closed.png";
		document.getElementById(elementID).innerHTML = '';
	}
	else
	{
		var xmlhttp; 
	 
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  
		xmlhttp.onreadystatechange=function()
		{
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				document.getElementById(imgID).src="../assets/images/tree/folder_open.png";
				document.getElementById(elementID).innerHTML=xmlhttp.responseText;
			}
		}
	
		xmlhttp.open("GET","../includes/custom/adminexpandpage.php?section="+section+"&id="+id,true);
		xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		xmlhttp.send();
	}	
}

/*********************************************
This function is using ajax to call adminpageselect.php file to load the children of current page
*********************************************/
function ExpandPage(id,flag,moveFlag){
	
	var elementID='div'+id;

	if (id=="")
	{
	  	document.getElementById(elementID).innerHTML="";	  
	  	return;
	} 
	if (document.getElementById(elementID).innerHTML!="")
	{
	  	document.getElementById(elementID).innerHTML="";
	  	document.getElementById("img_"+id).src="../assets/images/tree/folder_closed.png";
	  	if(moveFlag==true)
	  	{
	  		document.getElementById("img_up").style.display="none";
	  		document.getElementById("img_down").style.display="none";
	  	}
	  	try
	  	{
	  		var lblid=document.getElementById("lblSelected").innerHTML;
			var lblsection= document.getElementById("p-section").value;
			var tmp;
			if(lblid!='')
			{
				tmp=document.getElementById('div'+lblid).innerHTML;
			}
			else
			{
				tmp=document.getElementById('div'+lblsection).innerHTML;
			}
	  	}
		catch(err)
		{
		  	if(moveFlag==true)
		  	{
				document.getElementById("lblSelected").innerHTML='';
				document.getElementById("lblSelectedParent").innerHTML='';
				document.getElementById("lblSelectedSection").innerHTML='';
		  	}
		  	else
		  	{
			  	document.getElementById("lblSelected").innerHTML='';
			  	document.getElementById("p-parent").value='';
	          	document.getElementById("p-section").value='';
		  	}
	  	}
	  	return;
	} 
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
  
	xmlhttp.onreadystatechange=function()
	{
	  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("img_"+id).src="../assets/images/tree/folder_open.png";
			document.getElementById(elementID).innerHTML=xmlhttp.responseText;
		}
	}
	
	if(moveFlag==true)
	{
	  	if(flag==true)
	  	{
		  	xmlhttp.open("GET","../includes/custom/adminpageselect.php?id="+id+"&top="+true+"&move="+true,true);
	  	}
	  	else 
	  	{
		  	xmlhttp.open("GET","../includes/custom/adminpageselect.php?id="+id+"&top="+false+"&move="+true,true);
	  	}
	}
	else
	{
	 	if(flag==true)
	  	{
		 	xmlhttp.open("GET","../includes/custom/adminpageselect.php?id="+id+"&top="+true+"&move="+false,true);
	  	}
	  	else 
	  	{
		 	xmlhttp.open("GET","../includes/custom/adminpageselect.php?id="+id+"&top="+false+"&move="+false,true);
	  	}
	}
	xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp.send();
}

function Expand(id){
	var elementID='div'+id;
	if (id=="")
	{
	  document.getElementById(elementID).innerHTML="";
	  return;
	} 
	if (document.getElementById(elementID).innerHTML!="")
	{
	  document.getElementById(elementID).innerHTML="";
	  document.getElementById("img_"+id).src="../assets/images/tree/folder_closed.png";
	  return;
	} 
	//if (window.XDomainRequest) // Check whether the browser supports XDR. 
//    {//alert ("123");
//        xdr = new XDomainRequest(); // Create a new XDR object.
//				
//		// There is an error and the request cannot be completed. 
//		// The URL is preset in the text area. This is passed in the 
//		// open call with a get request.
//		xdr.onerror = err;
//        xdr.ontimeout = timeo;
//        xdr.onprogress = progres;
//		;
//        xdr.onload = function(){
//			document.getElementById(elementID).innerHTML=xdr.responseText;
//			xdr.abort();
//		}
//		xdr.open("GET","../includes/custom/adminpageselect.php?id="+id);
//				
//		// The request is then sent to the server.  
//		xdr.send()
//		
//
//	}
//	else{
	  	if (window.XMLHttpRequest)
	  	{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
	  	}
	  	else
	  	{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  	}
	  
		xmlhttp.onreadystatechange=function()
		{
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
				document.getElementById("img_"+id).src="../assets/images/tree/folder_open.png";
				document.getElementById(elementID).innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET","../includes/custom/adminpageselect.php?id="+id+"&top="+false,true);
		xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
		xmlhttp.send();
//	}

}

/*
* AJAX show the live search
*/
function showSearchResult(value,pageID)
{
	var filter_glossary = "";
	if(pageID == 'adminglossary'){
		
		filter_glossary = document.getElementById('id_search_filter').value;
	}
	
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function()
  	{
  		if (xmlhttp.readyState==4 && xmlhttp.status==200)
    	{
    		document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    	}
  	}
	if(filter_glossary == ""){
		
		xmlhttp.open("GET","../includes/custom/adminlivesearch.php?v="+value+"&id="+pageID,true);
	}
	else{
		xmlhttp.open("GET","../includes/custom/adminlivesearch.php?v="+value+"&id="+pageID+"&filter="+filter_glossary,true);
	}
	xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp.send();
}

function uploadnumber(number)
{
	document.getElementById('divfile').innerHTML=''
	for(var i=0;i<number;i++)
	{
		document.getElementById('divfile').innerHTML+='<input type="file" name="uploadfile[]" id="uploadfile[]"/><br/>';
	}
}

/**************************************
Display control panel in the adminpages.php
**************************************/
function ShowControlPanel(status,id)
{
	var content = "<div align='right'><a href=\"javascript:HideControlPanel('"+id+"')\" style=\"text-decoration: none\" border=\"0\"><img border='0' src='http://www.zone4.com.au/dev/gasleaks/site_specific/assets/images/wrong.png'/></a></div>";
		
	content += "<div>";
	
	content += "<b>Page id:"+id+"</b><br/>";
		
	content += "<b>Page Status:"+status+"</b><br/>";
	
	content += "<b>Move:</b>"+"<a href=\"javascript:launchPageMove('"+id+"');\">Move</a>"+"<br/>";
	
	content += "<b>Preview:</b>"+"<a href=\"javascript:launchPagePreview('" +id+ "');\">Preview</a>"+"<br/>";
	
	content += "<b>Content:</b>"+"<a href=\"javascript:editPageContent('"  +id+ "');\">Content</a>"+"<br/>";
	
	content += "<b>Action:</b>"+"<a href=\"javascript:doAction('edit', '"+id+"', false);\">Edit</a> / <a href=\"javascript:doAction('remove', '"+id+ "', true);\">Remove</a>";
						
	content += "</div>";
		
	document.getElementById('DIV_ADMINPAGES_RIGHT').innerHTML = content;
	
	
	
	for(var i=0;i<document.getElementById('DIV_ADMINPAGES_LEFT').getElementsByTagName('a').length;i++)
	{
		document.getElementById('DIV_ADMINPAGES_LEFT').getElementsByTagName('a').item(i).style.backgroundColor='#FFFFFF';
	}
	
	document.getElementById('a_'+id).style.background = '#5858FA';
	
}

/******************************************
Hide control panel in the adminpages.php
********************************************/
function HideControlPanel(id)
{
	document.getElementById('DIV_ADMINPAGES_RIGHT').innerHTML = '';
	document.getElementById('a_'+id).style.background = '#FFFFFF';
}

/********************************************
Display Junk box Control Panel
**********************************************/
function ShowJunkboxControlPanel(status,id){
	
	var content = "<div align='right'><a href=\"javascript:HideJunkboxControlPanel('"+id+"')\" style=\"text-decoration: none\" border=\"0\"><img border='0' src='http://www.zone4.com.au/dev/gasleaks/site_specific/assets/images/wrong.png'/></a></div>";
		
	content += "<div>";
	
	content += "<b>Page id:"+id+"</b><br/>";
		
	content += "<b>Page Status:"+status+"</b><br/>";
	
	content += "<b>Restore:</b>"+"<a href=\"javascript:doAction('restore', '" +id+ "', false);\">Restore</a>";
						
	content += "</div>";
		
	document.getElementById('DIV_ADMINPAGES_RIGHT').innerHTML = content;
	
	
	
	for(var i=0;i<document.getElementById('DIV_ADMINPAGES_LEFT').getElementsByTagName('a').length;i++)
	{
		document.getElementById('DIV_ADMINPAGES_LEFT').getElementsByTagName('a').item(i).style.backgroundColor='#FFFFFF';
	}
	
	document.getElementById('a_'+id+'_junk').style.background = '#5858FA';
}

/*****************************************
Hide Junk box Control Panel
***********************************************/
function HideJunkboxControlPanel(id){
	
	document.getElementById('DIV_ADMINPAGES_RIGHT').innerHTML = '';
	document.getElementById('a_'+id+'_junk').style.background = '#FFFFFF';
}
